package cc.comac.mom.datahandlers.entity;

import java.util.ArrayList;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import org.springframework.transaction.annotation.Transactional;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;

import cc.comac.mom.bean.EquipDev;
import cc.comac.mom.bean.EquipDevBean;
import cc.comac.mom.bean.EquipDevHistory;
import cc.comac.mom.bean.EquipParamItem;
import cc.comac.mom.bean.ResultDev;
import cc.comac.mom.dao.entity.EquipDevAppendDao;
import cc.comac.mom.dao.entity.EquipDevAreaDefDao;
import cc.comac.mom.dao.entity.EquipDevCategoryDao;
import cc.comac.mom.dao.entity.EquipDevDao;
import cc.comac.mom.dao.entity.EquipDevOpParamDao;
import cc.comac.mom.entity.EquipDevAppendEntity;
import cc.comac.mom.entity.EquipDevAreaDefEntity;
import cc.comac.mom.entity.EquipDevCategoryEntity;
import cc.comac.mom.entity.EquipDevEntity;
import cc.comac.mom.entity.EquipDevHistoryEntity;
import cc.comac.mom.entity.EquipDevOpParamEntity;
import cc.comac.mom.entity.EquipOperatorEntity;
import cc.comac.mom.util.BaseEntityDataUtil;
import cc.comac.mom.util.ResultBean;
import cc.comac.mom.util.TimeUtil;

@Component
@Transactional
public class EquipDevDataHandler extends ServiceImpl<EquipDevDao, EquipDevEntity> {
	@Autowired
	private EquipDevDao equipDevDao;
	@Autowired
	private EquipDevOpParamDao equipDevOpParamDao;
	@Autowired
	private EquipDevAppendDao equipDevAppendDao;
	@Autowired
	private EquipDevAreaDefDao equipDevAreaDefDao;
	@Autowired
	private EquipDevCategoryDao equipDevCategoryDao;

	@Autowired
	private EquipOperatorDataHandler equipOperatorDataHandler;

	@Autowired
	private EquipParamItemDataHandler equipParamItemDataHandler;

	@Autowired
	private BaseEntityDataUtil baseEntityDataUtil;

	@Autowired
	private EquipDevHistoryDataHandler equipDevHistoryDataHandler;

	public ResultBean save(EquipDev obj) {
		ResultBean resultBean = new ResultBean(true);
		// TODO Auto-generated method stub
		ResultBean resultBean2 = this.checkData(obj);
		if (!resultBean2.success) {
			return resultBean2;
		}
		// 校验主数据重复性
		Map<String, Object> map = new HashMap<String, Object>();
		map.put("dev_number", obj.getInnerData().getDevNumber());
		map.put("row_status", 1);
		List<EquipDevEntity> selectByMap = equipDevDao.selectByMap(map);
		if (selectByMap.size() > 0) {
			throw new RuntimeException("设备编号：" + obj.getInnerData().getDevNumber() + "已经存在");	
		}

		Map<String, Object> map1 = new HashMap<String, Object>();
		map1.put("dev_name", obj.getInnerData().getDevName());
		map1.put("row_status", 1);
		List<EquipDevEntity> selectByMap1 = equipDevDao.selectByMap(map1);
		if (selectByMap1.size() > 0) {
			throw new RuntimeException("设备名称：" + obj.getInnerData().getDevName() + "已经存在");	
		}
		baseEntityDataUtil.setBaseEntityData(obj.getInnerData());
		int insert = equipDevDao.insert(obj.getInnerData());
		if (insert < 1) {
			throw new RuntimeException("新增失败");	
		}
		// 保存设备履历数据
		insertDevHistory(obj.getInnerData(),"");
		
		resultBean.setObject(obj.getInnerData());
		return resultBean;
	}

	// 记录设备履历数据
	public void insertDevHistory(EquipDevEntity equipDevEntity,String propertyStatus) {
		EquipDevHistory equipDevHistory = new EquipDevHistory();
		EquipDevHistoryEntity equipDevHistoryEntity = new EquipDevHistoryEntity();
		equipDevHistory.setInnerData(equipDevHistoryEntity);
		equipDevHistoryEntity.setDevId(equipDevEntity.getId());
		equipDevHistoryEntity.setDevNumber(equipDevEntity.getDevNumber());
		if (org.apache.commons.lang.StringUtils.isEmpty(propertyStatus)) {
			equipDevHistoryEntity.setOperationDetail("设备入账");
			equipDevHistoryEntity.setOperationStyle("设备入账");
		} else {
			equipDevHistoryEntity.setOperationDetail(propertyStatus+" 更改为  "+equipDevEntity.getPropertyStatus());
			equipDevHistoryEntity.setOperationStyle("更新");
		}
		equipDevHistoryEntity.setRecordTime(equipDevEntity.getProductionDate());
		equipDevHistoryEntity.setOperator(baseEntityDataUtil.getCurrentUser());
		baseEntityDataUtil.setBaseEntityData(equipDevHistoryEntity);
		equipDevHistoryDataHandler.insertHistory(equipDevHistory);
	}

	/**
	 * 批量导入
	 * 
	 * @Title: importBatch
	 * @Description:
	 * @param list
	 * @return
	 *
	 */
	public ResultBean importBatch(List<EquipDevEntity> list) {
		ResultBean resultBean = new ResultBean(true);
		if (list == null || list.size() < 1) {
			throw new RuntimeException("导入数据为空");	
		}
		for (EquipDevEntity item : list) {
			baseEntityDataUtil.setBaseEntityData(item);
		}
		boolean saveBatch = this.saveBatch(list);
		if (!saveBatch) {
			throw new RuntimeException("导入失败");
		}
		resultBean.setMessage("成功导入:" + list.size() + "条数据");
		return resultBean;
	}

	/**
	 * 
	 * @Title: updateInventoryDate
	 * @Description: 修改盘点日期
	 * @param listIds
	 * @return
	 *
	 */
	public ResultBean updateInventoryDate(List<Long> listIds) {
		ResultBean resultBean = new ResultBean(true);
		if (listIds == null || listIds.size() < 1) {
			throw new RuntimeException("数据为空");
		}
		List<EquipDevEntity> selectBatchIds = equipDevDao.selectBatchIds(listIds);
		if (selectBatchIds == null || selectBatchIds.size() < 1) {
			throw new RuntimeException("数据为空");
		}
		// 操作记录list
		ArrayList<EquipOperatorEntity> listEquipOperatorEntity = new ArrayList<EquipOperatorEntity>();
		for (EquipDevEntity item : selectBatchIds) {
			Date inventoryDate = TimeUtil.getLocalDate();
			item.setInventoryDate(inventoryDate);
			baseEntityDataUtil.updateBaseEntityData(item);
			// 操作记录
			EquipOperatorEntity operatorEntity = new EquipOperatorEntity();
			operatorEntity.setOperation("设备主数据-修改");
			operatorEntity.setContent(item.getDevNumber() + ":" + item.getDevName() + ":" + "盘点日期修改为"
					+ TimeUtil.fomatDate(inventoryDate));
			baseEntityDataUtil.setBaseEntityData(operatorEntity);
			listEquipOperatorEntity.add(operatorEntity);
		}
		boolean updateBatchById = super.updateBatchById(selectBatchIds);
		if (!updateBatchById) {
			throw new RuntimeException("盘点日期修改失败！");
		}
		boolean saveBatch = equipOperatorDataHandler.saveBatch(listEquipOperatorEntity);
		if (!saveBatch) {
			throw new RuntimeException("设备主数据保存操作记录失败");
		}
		return resultBean;
	}

	public ResultBean update(EquipDev obj) {
		ResultBean resultBean = new ResultBean(true);
		// TODO Auto-generated method stub
		ResultBean resultBean2 = this.checkData(obj);
		if (!resultBean2.success) {
			return resultBean2;
		}

		EquipDevEntity equipDevEntity = equipDevDao.selectById(obj.getInnerData().getId());
		if (equipDevEntity == null) {
			throw new RuntimeException("修改的数据不存在！");
		}
		if (!equipDevEntity.getDevNumber().equals(obj.getInnerData().getDevNumber())) {
			throw new RuntimeException("设备编号:" + equipDevEntity.getDevNumber() + "不能修改");
		}

		Map<String, Object> map1 = new HashMap<String, Object>();
		map1.put("dev_name", obj.getInnerData().getDevName());
		map1.put("row_status", 1);
		List<EquipDevEntity> selectByMap1 = equipDevDao.selectByMap(map1);
		if (selectByMap1.size() > 0) {
			for (EquipDevEntity e : selectByMap1) {
				if (obj.getInnerData().getId() != e.getId()) {
					throw new RuntimeException("设备类型名称"+obj.getInnerData().getDevName()+"已存在！");
				}
			}
		}


		if (equipDevEntity.getDevCategoryId() != obj.getInnerData().getDevCategoryId()) {
			Map<String, Object> map = new HashMap<String, Object>();
			map.put("dev_id", obj.getInnerData().getId());
			map.put("row_status", 1);
			List<EquipDevAppendEntity> selectByMap = equipDevAppendDao.selectByMap(map);
			if (selectByMap != null && selectByMap.size() > 0) {
				throw new RuntimeException("该主数据存在附属信息，设备类型不能修改");
			}
			List<EquipDevOpParamEntity> selectByMap2 = equipDevOpParamDao.selectByMap(map);
			if (selectByMap2 != null && selectByMap2.size() > 0) {
				throw new RuntimeException("该主数据存在运行参数，设备类型不能修改");
			}
			List<EquipDevAreaDefEntity> selectByMap3 = equipDevAreaDefDao.selectByMap(map);
			if (selectByMap3 != null && selectByMap2.size() > 0) {
				throw new RuntimeException("该主数据存在部位定义，设备类型不能修改");
			}
		}
		baseEntityDataUtil.updateBaseEntityData(obj.getInnerData());
		int update = equipDevDao.updateById(obj.getInnerData());
		if (update < 1) {
			throw new RuntimeException("修改失败");
		}
		if (!equipDevEntity.getPropertyStatus().equals(obj.getInnerData().getPropertyStatus())) {
			insertDevHistory(equipDevEntity,equipDevEntity.getPropertyStatus());
		}
		// 操作记录
		EquipOperatorEntity equipOperatorEntity = new EquipOperatorEntity();
		equipOperatorEntity.setOperation("设备主数据-修改");
		baseEntityDataUtil.setBaseEntityData(equipOperatorEntity);
		StringBuffer content = new StringBuffer("设备编号：" + equipDevEntity.getDevNumber());
		// String content ="设备编号："+equipDevEntity.getDevNumber();
		if (equipDevEntity.getDevCategoryId() != obj.getInnerData().getDevCategoryId()) {
			EquipDevCategoryEntity CategoryEntityOld = equipDevCategoryDao
					.selectById(equipDevEntity.getDevCategoryId());
			EquipDevCategoryEntity CategoryEntityNew = equipDevCategoryDao
					.selectById(obj.getInnerData().getDevCategoryId());
			content.append(",设备类型:" + CategoryEntityOld.getDevCategoryName() + " 修改为: "
					+ CategoryEntityNew.getDevCategoryName());
		}
		if (!StringUtils.equals(equipDevEntity.getDevName(), obj.getInnerData().getDevName())) {
			content.append(
					",设备名称:\"" + equipDevEntity.getDevName() + "\" 修改为: \"" + obj.getInnerData().getDevName() + "\"");
		}
		if (!StringUtils.equals(equipDevEntity.getDevModel(), obj.getInnerData().getDevModel())) {
			content.append(",规格型号: \"" + equipDevEntity.getDevModel() + "\" 修改为: \"" + obj.getInnerData().getDevModel()
					+ "\"");
		}
		if (!StringUtils.equals(equipDevEntity.getDevUnit(), obj.getInnerData().getDevUnit())) {
			content.append(
					",计量单位: \"" + equipDevEntity.getDevUnit() + "\" 修改为: \"" + obj.getInnerData().getDevUnit() + "\"");
		}
		if (!StringUtils.equals(equipDevEntity.getSupplierName(), obj.getInnerData().getSupplierName())) {
			content.append(",品牌商: \"" + equipDevEntity.getSupplierName() + "\" 修改为: \""
					+ obj.getInnerData().getSupplierName() + "\"");
		}
		if (!StringUtils.equals(equipDevEntity.getPropertyType(), obj.getInnerData().getPropertyType())) {
			content.append(",资产类别: \"" + equipDevEntity.getDevModel() + "\" 修改为: \""
					+ obj.getInnerData().getPropertyType() + "\"");
		}
		if (!StringUtils.equals(equipDevEntity.getPropertyStatus(), obj.getInnerData().getPropertyStatus())) {
			content.append(",资产状态: \"" + equipDevEntity.getPropertyStatus() + "\" 修改为: \""
					+ obj.getInnerData().getPropertyStatus() + "\"");
		}
		if (!StringUtils.equals(equipDevEntity.getDevRemark(), obj.getInnerData().getDevRemark())) {
			content.append(",备注: \"" + equipDevEntity.getDevRemark() + "\" 修改为: \"" + obj.getInnerData().getDevRemark()
					+ "\"");
		}
		if (equipDevEntity.getProductionDate() == null || obj.getInnerData().getProductionDate() == null) {
			if (equipDevEntity.getProductionDate() == null && obj.getInnerData().getProductionDate() != null) {
				content.append(",入账日期: 修改为: \"" + TimeUtil.fomatDate(obj.getInnerData().getProductionDate()) + "\"");
			} else if (equipDevEntity.getExpiryDate() != null && obj.getInnerData().getProductionDate() == null) {
				content.append(",入账日期: \"" + TimeUtil.fomatDate(equipDevEntity.getProductionDate()) + "\" 置空");
			}

		} else {
			if (!equipDevEntity.getProductionDate().equals(obj.getInnerData().getProductionDate())) {
				content.append(",入账日期: \"" + TimeUtil.fomatDate(equipDevEntity.getProductionDate()) + "\" 修改为: \""
						+ TimeUtil.fomatDate(obj.getInnerData().getProductionDate()) + "\"");
			}
		}
		if (!StringUtils.equals(equipDevEntity.getDevStatus(), obj.getInnerData().getDevStatus())) {
			EquipParamItem equipParamItem = new EquipParamItem();
			equipParamItem.setParamName("DevEquipment");
			equipParamItem.setParamItemName(equipDevEntity.getDevStatus());
			EquipParamItem paramItemOld = equipParamItemDataHandler
					.returnSelectAllByParamNameandParamItemName(equipParamItem);

			equipParamItem.setParamItemName(obj.getInnerData().getDevStatus());
			EquipParamItem paramItemNow = equipParamItemDataHandler
					.returnSelectAllByParamNameandParamItemName(equipParamItem);

			content.append(",设备状态: \"" + paramItemOld.getEntityList().get(0).getParamItemValue() + "\" 修改为: \""
					+ paramItemNow.getEntityList().get(0).getParamItemValue() + "\"");

		}
		if (!StringUtils.equals(equipDevEntity.getUserDepartment(), obj.getInnerData().getUserDepartment())) {
			content.append(",使用部门: \"" + equipDevEntity.getUserDepartment() + "\" 修改为: \""
					+ obj.getInnerData().getUserDepartment() + "\"");
		}
		if (!StringUtils.equals(equipDevEntity.getWorkShop(), obj.getInnerData().getWorkShop())) {
			EquipParamItem equipParamItem = new EquipParamItem();
			equipParamItem.setParamName("Place");
			equipParamItem.setParamItemName(equipDevEntity.getWorkShop());
			EquipParamItem paramItemOld = equipParamItemDataHandler
					.returnSelectAllByParamNameandParamItemName(equipParamItem);

			equipParamItem.setParamItemName(obj.getInnerData().getWorkShop());
			EquipParamItem paramItemNow = equipParamItemDataHandler
					.returnSelectAllByParamNameandParamItemName(equipParamItem);

			content.append(",所在位置: \"" + paramItemOld.getEntityList().get(0).getParamItemValue() + "\" 修改为: \""
					+ paramItemNow.getEntityList().get(0).getParamItemValue() + "\"");

		}

		if (!StringUtils.equals(equipDevEntity.getLocation(), obj.getInnerData().getLocation())) {
			content.append(",具体位置: \"" + equipDevEntity.getLocation() + "\" 修改为: \"" + obj.getInnerData().getLocation()
					+ "\"");
		}
		if (!StringUtils.equals(equipDevEntity.getMaintenanceTeam(), obj.getInnerData().getMaintenanceTeam())) {
			content.append(",维修组: \"" + equipDevEntity.getMaintenanceTeam() + "\" 修改为: \""
					+ obj.getInnerData().getMaintenanceTeam() + "\"");
		}
		if (!StringUtils.equals(equipDevEntity.getResDepartmentGroup(), obj.getInnerData().getResDepartmentGroup())) {
			content.append(",使用部门班组: \"" + equipDevEntity.getResDepartmentGroup() + "\" 修改为: \""
					+ obj.getInnerData().getResDepartmentGroup() + "\"");
		}
		if (!StringUtils.equals(equipDevEntity.getResDepartmentLeader(), obj.getInnerData().getResDepartmentLeader())) {
			content.append(",使用部门领导: \"" + equipDevEntity.getResDepartmentLeader() + "\" 修改为: \""
					+ obj.getInnerData().getResDepartmentLeader() + "\"");
		}
		if (!StringUtils.equals(equipDevEntity.getResDepartmentPerson(), obj.getInnerData().getResDepartmentPerson())) {
			content.append(",使用责任人: \"" + equipDevEntity.getResDepartmentPerson() + "\" 修改为: \""
					+ obj.getInnerData().getResDepartmentPerson() + "\"");
		}
		if (equipDevEntity.getAssessment() != obj.getInnerData().getAssessment()) {
			if (equipDevEntity.getAssessment() == 1) {

				content.append(",是否考核: \"是\" 修改为: \"否\"");
			} else {
				content.append(",是否考核: \"否\" 修改为: \"是\"");
			}
		}
		if (!StringUtils.equals(equipDevEntity.getAssessmentCycle(), obj.getInnerData().getAssessmentCycle())) {
			content.append(",考核周期: \"" + equipDevEntity.getAssessmentCycle() + "\" 修改为: \""
					+ obj.getInnerData().getAssessmentCycle() + "\"");
		}
		if (equipDevEntity.getResultStatus() != obj.getInnerData().getResultStatus()) {
			if (equipDevEntity.getResultStatus() == 1) {

				content.append(",完好状态: \"是\" 修改为: \"否\"");
			} else {
				content.append(",完好状态: \"否\" 修改为: \"是\"");
			}
		}
		if (equipDevEntity.getExpiryDate() == null || obj.getInnerData().getExpiryDate() == null) {
			if (equipDevEntity.getExpiryDate() == null && obj.getInnerData().getExpiryDate() != null) {
				content.append(",完好有效期: 修改为: \"" + TimeUtil.fomatDate(obj.getInnerData().getExpiryDate()) + "\"");
			} else if (equipDevEntity.getExpiryDate() != null && obj.getInnerData().getExpiryDate() == null) {
				content.append(",完好有效期: \"" + TimeUtil.fomatDate(equipDevEntity.getExpiryDate()) + "\" 置空");
			}

		} else {
			if (!equipDevEntity.getExpiryDate().equals(obj.getInnerData().getExpiryDate())) {
				content.append(",完好有效期: \"" + TimeUtil.fomatDate(equipDevEntity.getExpiryDate()) + "\" 修改为: \""
						+ TimeUtil.fomatDate(obj.getInnerData().getExpiryDate()) + "\"");
			}
		}
		equipOperatorEntity.setContent(content.toString());
		if(content.toString().length()>("设备编号：" + equipDevEntity.getDevNumber()).length()) {
			boolean save = equipOperatorDataHandler.save(equipOperatorEntity);
			if (!save) {
				throw new RuntimeException("设备主数据保存操作记录保存失败");
			}
		}

		return resultBean;
	}

	public ResultBean delete(EquipDev obj) {
		ResultBean resultBean = new ResultBean(true);
		// TODO Auto-generated method stub
		if (obj == null) {
			throw new RuntimeException("数据为空");
		}
		EquipDevEntity innerData = obj.getInnerData();
		if (innerData == null) {
			throw new RuntimeException("数据为空");
		}
		EquipDevEntity equipDevEntity = equipDevDao.selectById(innerData.getId());
		if (equipDevEntity == null) {
			throw new RuntimeException("删除的数据不存在！");
		}
//		if(!equipDevEntity.getDevStatus().equals("SCRAP")) {
//			resultBean.setSuccess(false);
//			resultBean.setMessage("只有报废状态下的设备才能删除！");
//			return resultBean;
//		}
		if (!equipDevEntity.getPropertyStatus().contains("报废")) {
			throw new RuntimeException("资产状态为报废状态下的设备才能删除！");
		}
		equipDevEntity.setRowStatus(0);
		int updateById = equipDevDao.updateById(equipDevEntity);
		if (updateById < 1) {
			throw new RuntimeException("删除失败！");
		}
		return resultBean;
	}

	public EquipDev getById(long id) {
		// TODO Auto-generated method stub
		EquipDevEntity equipDevEntity = equipDevDao.selectById(id);
		if (equipDevEntity != null) {
			EquipDev equipDev = new EquipDev();
			equipDev.setInnerData(equipDevEntity);
			return equipDev;
		}
		return null;
	}

	public ResultBean checkData(EquipDev obj) {
		ResultBean resultBean = new ResultBean(true);
		if (obj == null) {
			throw new RuntimeException("数据为空");
		}
		EquipDevEntity innerData = obj.getInnerData();
		if (innerData == null) {
			throw new RuntimeException("数据为空");
		}

		if (innerData.getDevNumber() == null || "".equals(innerData.getDevNumber())) {
			throw new RuntimeException("设备编号不能为空");
		}
		if (innerData.getDevCategoryId() == 0) {
			throw new RuntimeException("设备类型不能为空");
		}
		if (innerData.getDevStatus() == null || "".equals(innerData.getDevStatus())) {
			throw new RuntimeException("设备类型不能为空");
		}

		if (innerData.getUserDepartment() == null || "".equals(innerData.getUserDepartment())) {
			throw new RuntimeException("使用部门不能为空");
		}
		if (innerData.getWorkShop() == null || "".equals(innerData.getWorkShop())) {
			throw new RuntimeException("所在位置不能为空");
		}
		if (innerData.getLocation() == null || "".equals(innerData.getLocation())) {
			throw new RuntimeException("具体位置不能为空");
		}
		if (innerData.getMaintenanceTeam() == null || "".equals(innerData.getMaintenanceTeam())) {
			throw new RuntimeException("维修组不能为空");
			
		}
		if (innerData.getResDepartmentGroup() == null || "".equals(innerData.getResDepartmentGroup())) {
			throw new RuntimeException("使用部门班组不能为空");
		}
		return resultBean;

	}

	public EquipDevBean selectByCondition(EquipDev obj) {

		QueryWrapper<EquipDevEntity> queryWrapper = new QueryWrapper<EquipDevEntity>();
		queryWrapper.eq("row_status", 1);
		if (obj != null && obj.getInnerData() != null) {
			if (obj.getInnerData().getDevNumber() != null && !"".equals(obj.getInnerData().getDevNumber())) {
				queryWrapper.like("dev_number", obj.getInnerData().getDevNumber());
			}
			if (obj.getInnerData().getDevName() != null && !"".equals(obj.getInnerData().getDevName())) {
				queryWrapper.like("dev_name", obj.getInnerData().getDevName());
			}
			if (obj.getInnerData().getDevModel() != null && !"".equals(obj.getInnerData().getDevModel())) {
				queryWrapper.like("dev_model", obj.getInnerData().getDevModel());
			}
			if (obj.getInnerData().getDevCategoryId() != 0) {
				queryWrapper.eq("dev_category_id", obj.getInnerData().getDevCategoryId());
			}
			if (obj.getInnerData().getDevStatus() != null && !"".equals(obj.getInnerData().getDevStatus())) {
				queryWrapper.like("dev_status", obj.getInnerData().getDevStatus());
			}
			if (obj.getInnerData().getSupplierName() != null && !"".equals(obj.getInnerData().getSupplierName())) {
				queryWrapper.like("supplier_name", obj.getInnerData().getSupplierName());
			}
			if (obj.getInnerData().getWorkShop() != null && !"".equals(obj.getInnerData().getWorkShop())) {
				queryWrapper.eq("work_shop", obj.getInnerData().getWorkShop());
			}
			if (obj.getPropertyStatusList() != null && obj.getPropertyStatusList().size()>0) {
				queryWrapper.in("property_status", obj.getPropertyStatusList());
			}
			if (obj.getInnerData().getLocation() != null && !"".equals(obj.getInnerData().getLocation())) {
				queryWrapper.like("location", obj.getInnerData().getLocation());
			}
		}
		Page<EquipDevEntity> page = new Page<>(obj.getPageNum(), obj.getPageSize(), true);
		IPage<EquipDevEntity> iPage = equipDevDao.selectPage(page, queryWrapper);
		List<EquipDevEntity> list = iPage.getRecords();
		if (list != null && list.size() > 0) {
			long pages = iPage.getPages();
			long total = iPage.getTotal();
			ArrayList<EquipDev> arrayList = new ArrayList<EquipDev>();
			for (EquipDevEntity item : list) {
				EquipDev equipDev = new EquipDev();
				equipDev.setInnerData(item);
				arrayList.add(equipDev);
			}
			EquipDevBean equipDevBean = new EquipDevBean();
			equipDevBean.setList(arrayList);
			equipDevBean.setPageNum(obj.getPageNum());
			equipDevBean.setPageSize(obj.getPageSize());
			equipDevBean.setPages((int) pages);
			equipDevBean.setTotal((int) total);
			return equipDevBean;
		}
		return new EquipDevBean();
	}

	public List<EquipDevBean> select(EquipDevBean obj) {


		List<EquipDevBean> list = equipDevDao.selectDevInfo(obj);

		return list;
	}

	public ResultDev selectAllData() {
		ResultDev resultDev = new ResultDev();
		QueryWrapper<EquipDevEntity> queryWrapper = new QueryWrapper<EquipDevEntity>();
		queryWrapper.eq("row_status", 1);
		List<EquipDevEntity> selectList = equipDevDao.selectList(queryWrapper);
		resultDev.setEntityList(selectList);
		return resultDev;
	}

	public List<EquipDevBean> exportSelectByCondition(EquipDevBean obj) {

		return equipDevDao.exportSelectByCondition(obj);

	}

}
